package com.ruoyi.web.controller.pc.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.blogs.domain.BsFaq;
import com.ruoyi.blogs.service.IBsFaqService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.uuid.IdUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "问答")
@RestController
@RequestMapping("/user/faq")
public class UserFaqController extends BaseController{
    
    @Autowired
    private IBsFaqService bsFaqService;

    /**
     * 新增问答管理
     */
    @ApiOperation("发布问答")
    @PostMapping
    public R<Integer> add(@RequestBody BsFaq bsFaq)
    {
        bsFaq.setId(IdUtils.fastSimpleUUID());
        bsFaq.setVisible(0);
        bsFaq.setIsHot(0L);
        return R.ok(bsFaqService.insertBsFaq(bsFaq));
    }

    /**
     * 采纳回答（修改问答）
     */
    @ApiOperation("采纳回答（修改问答）")
    @PutMapping
    public R<Integer> edit(@RequestBody BsFaq bsFaq)
    {
        return R.ok(bsFaqService.updateBsFaq(bsFaq));
    }
}
